package com.ruoyi.address.service.impl;

import java.util.List;

import com.ruoyi.address.domain.vo.AddressVo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.address.mapper.AddressMapper;
import com.ruoyi.address.domain.Address;
import com.ruoyi.address.service.IAddressService;

/**
 * 收货地址信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-31
 */
@Service
public class AddressServiceImpl implements IAddressService 
{
    @Autowired
    private AddressMapper addressMapper;

    /**
     * 查询收货地址信息
     * 
     * @param addressId 收货地址信息主键
     * @return 收货地址信息
     */
    @Override
    public Address selectAddressByAddressId(Long addressId)
    {
        return addressMapper.selectAddressByAddressId(addressId);
    }

    /**
     * 查询收货地址信息列表
     * 
     * @param address 收货地址信息
     * @return 收货地址信息
     */
    @Override
    public List<Address> selectAddressList(Address address)
    {
        return addressMapper.selectAddressList(address);
    }

    /**
     * 新增收货地址信息
     * 
     * @param address 收货地址信息
     * @return 结果
     */
    @Override
    public int insertAddress(Address address)
    {
        // 数据类型不同，不能调用次方法
        // address.setAddressId(IdUtils.fastSimpleUUID());
        address.setCreateTime(DateUtils.getNowDate());
        return addressMapper.insertAddress(address);
    }

    /**
     * 修改收货地址信息
     * 
     * @param address 收货地址信息
     * @return 结果
     */
    @Override
    public int updateAddress(Address address)
    {
        address.setUpdateTime(DateUtils.getNowDate());
        return addressMapper.updateAddress(address);
    }

    /**
     * 批量删除收货地址信息
     * 
     * @param addressIds 需要删除的收货地址信息主键
     * @return 结果
     */
    @Override
    public int deleteAddressByAddressIds(Long[] addressIds)
    {
        return addressMapper.deleteAddressByAddressIds(addressIds);
    }

    /**
     * 删除收货地址信息信息
     * 
     * @param addressId 收货地址信息主键
     * @return 结果
     */
    @Override
    public int deleteAddressByAddressId(Long addressId)
    {
        return addressMapper.deleteAddressByAddressId(addressId);
    }


    /**
     * 展示收货地址信息的创建人信息
     *
     * @return AddressVo集合
     */
    @Override
    public List<AddressVo> selectAddressVoList(Address address) {
        return addressMapper.selectAddressVoList(address);
    }
}
